<?php
header("Content-type: text/html; charset=utf-8");
ini_set('display_errors', 1);
set_time_limit(0);
include_once dirname(dirname(__FILE__)) . '/mgtv_init.php';

//echo np_millitime_rand();
class create_integer_id extends nn_timer
{

	public function action($params = null)
	{
		$this->msg('开始执行...');
		do_timer_action();
		$this->msg('执行结束...');
	}
}
$create_integer_id = new create_integer_id("create_integer_id", 'public',__FILE__);
$create_integer_id->run();

function do_timer_action()
{
	$i = 0;
	$bool = true;
	$db = nn_get_db(NL_DB_WRITE);
	while ($bool)
	{
		$sql = "select * from nns_vod_index  limit $i,1";
		$info = nl_db_get_one($sql, $db);
		unset($sql);
		if (is_array($info) && !empty($info))
		{
			$id = np_millitime_rand();
			$update_sql = "update nns_vod_index set nns_integer_id='$id' where nns_id='{$info['nns_id']}'";
			//die($update_sql);
			nl_execute_by_db($update_sql, $db);
			echo $info['nns_name'] . PHP_EOL;
			unset($update_sql, $info);
		}
		else
		{
			$bool = false;
		}
		usleep(1000);
		$i++;
	}
}
